package com.ziyun.erp.modules.member.service.impl;

import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import com.ziyun.erp.modules.member.dao.UserShareDao;
import com.ziyun.erp.modules.member.entity.UserShareEntity;
import com.ziyun.erp.modules.member.service.UserShareService;


@Service("userShareService")
public class UserShareServiceImpl extends ServiceImpl<UserShareDao, UserShareEntity> implements UserShareService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<UserShareEntity> page = this.selectPage(
                new Query<UserShareEntity>(params).getPage(),
                new EntityWrapper<UserShareEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void reject(BigDecimal amount, Integer memberId) {
        baseMapper.reject(amount,memberId);
    }

    @Override
    public void pay(BigDecimal amount, Integer memberId) {
        baseMapper.pay(amount,memberId);
    }

    /**
     * 新增佣金
     * @param memberId
     * @param commission
     */
    @Override
    public boolean updateCommissionAdd(Integer memberId, BigDecimal commission,BigDecimal usableCommission) {
        int re = baseMapper.updateCommissionAdd(memberId,commission,usableCommission);
        if(re == 1){
            return true;
        }else{
            return false;
        }
    }

    @Override
    public boolean updateCommissionThawing(Integer memberId, BigDecimal commission, BigDecimal usableCommission) {
        int re = baseMapper.updateCommissionThawing(memberId,commission,usableCommission);
        if(re == 1){
            return true;
        }else{
            return false;
        }
    }

}
